package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.beans.annotation.LoginAdminId;
import org.linlinjava.litemall.admin.service.AdminLumierePackageCategoryService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumierePackageCategory;
import org.springframework.web.bind.annotation.*;

@Api(tags = "套餐类目管理API")
@RestController
@RequestMapping("admin/packageCategory")
@RequiredArgsConstructor
public class AdminLumierePackageCategoryController {

    private final AdminLumierePackageCategoryService adminLumierePackageCategoryService;

    @ApiOperation("套餐类目管理-查询套餐类目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit",value = "数量"),
            @ApiImplicitParam(name = "page",value = "当前页"),
            @ApiImplicitParam(name = "packageName",value = "套餐名称")
    })
    @LogAnno
    @GetMapping("/list")
    public ResponseUtil.Response list(@RequestParam("packageId") Integer packageId) {
        return adminLumierePackageCategoryService.listLumierePackageCategory(packageId);
    }

    @ApiOperation("套餐类目管理-查询套餐类目商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "packageId",value = "套餐id")
    })
    @LogAnno
    @GetMapping("/goods-list")
    public ResponseUtil.Response list(@RequestParam("packageId") Integer packageId,@RequestParam("packageCategoryId") Integer packageCategoryId) {
        return adminLumierePackageCategoryService.listLumierePackageCategoryGoods(packageId,packageCategoryId);
    }

    @ApiOperation("套餐类目管理-新增套餐类目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "packageName",value = "套餐名称"),
    })
    @LogAnno
    @PostMapping("/add")
    public ResponseUtil.Response add(@RequestBody LumierePackageCategory lumierePackageCategory, @LoginAdminId Integer adminUserId)  {
        return adminLumierePackageCategoryService.addLumierePackageCategory(lumierePackageCategory,adminUserId);
    }

    @ApiOperation("套餐类目管理-编辑套餐类目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "packageName",value = "套餐名称"),
    })
    @LogAnno
    @PutMapping ("/update")
    public ResponseUtil.Response update(@RequestBody LumierePackageCategory lumierePackageCategory)  {
        return adminLumierePackageCategoryService.updateLumierePackageCategory(lumierePackageCategory);
    }

    @ApiOperation("套餐类目管理-删除套餐类目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id"),
    })
    @LogAnno
    @DeleteMapping("/delete/{packageCategoryId}")
    public ResponseUtil.Response delete(@PathVariable("packageCategoryId") Integer id)  {
        return adminLumierePackageCategoryService.deleteLumierePackageCategory(id);
    }



}
